function carousel() {
  const $carousel = $('.pics-carousel');
  const $content = $('.cont');
  const $items = $content.children();
  const count = $items.length;

  let active = 0;

  $content.css('width', `${count}00%`);
  $items.css('width', `${100 / count}%`)


  const $ul = $('<ul class="dots _flex-v">');
  for(let j=0; j < count; j++) {
    const $li = $('<li class="dot">');
    $ul.append($li);
  }
  $carousel.append($ul);

  function dorChange() {
    $ul.children()
      .removeClass('_active')
    .eq(active)
      .addClass('_active');
  }
  function auto() {
    active = (active < count - 1) ? (active + 1) : 0;
    $content.css('left', `-${active}00%`);
    dorChange()
  }
  $carousel.timer = setInterval(auto, 2000);

  // 手动切换
  // function manual(left) {
  //   const nomore = left ? (active >= count - 1) : (active <= 0);
  //   const change = left ? 1 : -1;
  //   clearInterval(this.timer);
  //   if (nomore) return;
  //   active += change;
  //   $content.css('left', `-${active}00%`);
  //   dotChange();
  //   this.timer = setInterval(auto, speed);
  // }
  // $content.on('swipeLeft', manual.bind(this, true));
  // $content.on('swipeRight', manual.bind(this, false));
}
carousel();